package com.wp.module.wpArticleType.controller;

import com.wp.common.annotation.Log;
import com.wp.common.core.controller.BaseController;
import com.wp.common.core.domain.AjaxResult;
import com.wp.common.core.page.TableDataInfo;
import com.wp.common.enums.BusinessType;
import com.wp.module.wpArticleType.domain.WpArticleType;
import com.wp.module.wpArticleType.service.IWpArticleTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 帖子类型Controller
 * 
 * @author wp
 * @date 2025-02-24
 */
@RestController
@RequestMapping("/module/wpArticleType")
public class WpArticleTypeController extends BaseController
{
    @Autowired
    private IWpArticleTypeService wpArticleTypeService;

    /**
     * 查询帖子类型列表
     */
    @PreAuthorize("@ss.hasPermi('module:wpArticleType:list')")
    @GetMapping("/list")
    public TableDataInfo list(WpArticleType wpArticleType)
    {
        startPage();
        List<WpArticleType> list = wpArticleTypeService.selectWpArticleTypeList(wpArticleType);
        return getDataTable(list);
    }

    /**
     * 获取帖子类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('module:wpArticleType:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(wpArticleTypeService.selectWpArticleTypeById(id));
    }

    /**
     * 新增帖子类型
     */
    @PreAuthorize("@ss.hasPermi('module:wpArticleType:add')")
    @Log(title = "帖子类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WpArticleType wpArticleType)
    {
        return success(wpArticleTypeService.insertWpArticleType(wpArticleType));
    }

    /**
     * 修改帖子类型
     */
    @PreAuthorize("@ss.hasPermi('module:wpArticleType:edit')")
    @Log(title = "帖子类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WpArticleType wpArticleType)
    {
        return toAjax(wpArticleTypeService.updateWpArticleType(wpArticleType));
    }

    /**
     * 删除帖子类型
     */
    @PreAuthorize("@ss.hasPermi('module:wpArticleType:remove')")
    @Log(title = "帖子类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(wpArticleTypeService.deleteWpArticleTypeByIds(ids));
    }
}
